import cv2
import os

# 请修改为你的文件夹路径
hr_dir = "datasets/HR"    # HR文件夹
sr_dir = "datasets/SR"    # SR文件夹
suffix = "out"     # 和超分辨时的--suffix一致（默认是out）

print("SR与HR分辨率对比：")
print("="*50)

for hr_filename in os.listdir(hr_dir):
    if hr_filename.endswith((".jpg", ".png")):
        # 拼接HR和SR的完整路径
        hr_path = os.path.join(hr_dir, hr_filename)
        # SR文件名是「HR文件名_suffix.格式」（比如1.jpg → 1_out.jpg）
        sr_filename = f"{os.path.splitext(hr_filename)[0]}_{suffix}.{os.path.splitext(hr_filename)[1][1:]}"
        sr_path = os.path.join(sr_dir, sr_filename)

        # 读取图片并获取尺寸
        hr_img = cv2.imread(hr_path)
        sr_img = cv2.imread(sr_path)
        hr_h, hr_w = hr_img.shape[:2]
        sr_h, sr_w = sr_img.shape[:2]

        # 打印结果（一致会标✅，不一致标❌）
        status = "✅" if (hr_w == sr_w and hr_h == sr_h) else "❌"
        print(f"{hr_filename:<10} | HR: {hr_w}×{hr_h} | SR: {sr_w}×{sr_h} | {status}")

print("="*50)
